import React from 'react'
import { Button, message } from 'antd'
import usePubTableData from './common/pubTbaleData'
import NewsPublish from './common/pubTableConfig'
import http from '../../api'

export default function Unpublished() {
    const { pubTableData, getTableList } = usePubTableData(1)
    const handlePublish = (id) => {
        http.patch(`/news/${id}`, {
            publishState: 2,
            publishTime: Date.now()
        }).then(res => {
            getTableList()
            message.success('发布成功')
        })
    }
    return (
        <div>
            <NewsPublish dataSource={pubTableData} button={(id) => <Button onClick={() => handlePublish(id)}>发布</Button>} />
        </div>
    )
} 